package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.RecInfoEntity;
import com.jinmdz.fmis.mapper.mapper.provider.RecInfoProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 接运信息表Mapper
 *
 * @author generator
 * @date 2020-06-16 10:19
 */
public interface RecInfoMapper {

    /**
     * 增加RecInfo
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-06-16 10:19
     */
    @InsertProvider(type = RecInfoProvider.class, method = "insertRecInfo")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertRecInfo(@Param("entity") RecInfoEntity entity);

    /**
     * 删除RecInfo
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-06-16 10:19
     */
    @Update(" update rec_info set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForRecInfo(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改RecInfo
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-06-16 10:19
     */
    @UpdateProvider(type = RecInfoProvider.class, method = "updateRecInfo")
    void updateRecInfo(@Param("entity") RecInfoEntity entity);

    /**
     * 查询RecInfo实体
     *
     * @param id 主键
     * @return RecInfoEntity
     * @author generator
     * @date 2020-06-16 10:19
     */
    @Select(" select id,deleted,rec_code,contact,contact_phone,contact_type,dead_name,death_cause,relation_code,relation,car_type_code,car_type,purpose_code,purpose,arrival_time,rec_charge,body_deposit_code,body_deposit,address,sourceCode,source,task_state_code,task_state,chargeRemark,remark,appId,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from rec_info where id = #{id} and deleted = 0 limit 1 ")
    RecInfoEntity getRecInfoById(@Param("id") Integer id);

    /**
     * 查询RecInfo列表
     *
     * @param entity 数据实体
     * @return RecInfoEntity
     * @author generator
     * @date 2020-06-16 10:19
     */
    @SelectProvider(type = RecInfoProvider.class, method = "listRecInfo")
    ArrayList<RecInfoEntity> listRecInfo(@Param("entity") RecInfoEntity entity);
}